﻿using Modules.Person;
using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Payroll.PayrollConstants;
using static Modules.Person.PersonConstants;
using static Modules.System.Flow.FlowConstants;

namespace Modules
{
    /// <summary>
    /// 工资单
    ///</summary>
    [TableName("wage_payroll")]
    [Description("工资单")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, PropertyNamesOfArea = "WageStatus")]
    [Serializable]
    public class WagePayroll : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 工资单名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 项目Id
        ///</summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 企业id
        ///</summary>
        [Column("corp_id")]
        public int CorpId { get; set; }

        /// <summary>
        /// 开始日期
        ///</summary>
        [Column("start_date")]
        public DateTime StartDate { get; set; }

        /// <summary>
        /// 结束日期
        ///</summary>
        [Column("end_date")]
        public DateTime EndDate { get; set; }

        /// <summary>
        /// 编号
        ///</summary>
        [Column("code")]
        public string Code { get; set; }

        /// <summary>
        /// 流水号
        ///</summary>
        [Column("serial_number")]
        public int SerialNumber { get; set; }

        /// <summary>
        /// 审核类型
        ///</summary>
        [Column("audit_type")]
        public 审核类型 AuditType { get; set; }

        /// <summary>
        /// 审核状态
        ///</summary>
        [Column("audit_status")]
        public 审核状态 AuditStatus { get; set; }

        /// <summary>
        /// 代发月份
        ///</summary>
        [Column("month")]
        public int Month { get; set; }

        /// <summary>
        /// 支付方式( 工资结算模式 )
        ///</summary>
        [Column("pay_type")]
        public 工资计算方式 PayType { get; set; }

        /// <summary>
        /// 录入人数
        ///</summary>
        [Column("number_people")]
        public int NumberPeople { get; set; }

        /// <summary>
        /// 申请金额（工资单理应发放的总金额）
        ///</summary>
        [Column("amount_applied")]
        public decimal? AmountApplied { get; set; }

        /// <summary>
        /// 代发总金额(成功金额)
        ///</summary>
        [Column("total_amount")]
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 成功金额
        ///</summary>
        [Column("successful_amount")]
        public decimal? SuccessfulAmount { get; set; }

        /// <summary>
        /// 失败金额
        ///</summary>
        [Column("failure_amount")]
        public decimal? FailureAmount { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 流程编码
        ///</summary>
        [Column("flow_code")]
        public string FlowCode { get; set; }

        /// <summary>
        /// 流程步骤编码
        ///</summary>
        [Column("flow_engine_code")]
        public FlowEngine FlowEngineCode { get; set; }

        /// <summary>
        /// 当月计价总额
        ///</summary>
        [Column("total_valuation")]
        public decimal? TotalValuation { get; set; }

        /// <summary>
        /// 工资单类型
        /// </summary>
        [Column("wage_type")]
        public 工资单类型 WageType { get; set; }

        /// <summary>
        /// 代发状态（0：未发放 1：待发放 2：部分代发 3:代发完成 -1:已撤销 ）
        /// </summary>
        [Column("wage_status")]
        public 代发状态 WageStatus { get; set; }

        /// <summary>
        /// 代发成功人数
        /// </summary>
        [Column("wage_success_person_count")]
        public int? WageSuccessPersonCount { get; set; }

        /// <summary>
        /// 创建批量代发批次返回的银行统一支付流水号
        /// </summary>

        [Column("bank_payment_no")]
        public string? BankPaymentNo { get; set; }

        /// <summary>
        /// 创建批量代发批次返回的合同号
        /// </summary>

        [Column("contract_no")]
        public string? ContractNo { get; set; }

        /// <summary>
        /// 创建批量代发批次返回的批次号
        /// </summary>

        [Column("batch_no")]
        public string? BatchNo { get; set; }

        /// <summary>
        /// 是否提交给银行发放工资
        /// </summary>

        [Column("has_submit")]
        public bool HasSubmit { get; set; }

        /// <summary>
        /// 是否已创建批量代发
        /// </summary>

        [Column("has_create_batch")]
        public bool HasCreateBatch { get; set; }

        /// <summary>
        /// 代发失败原因
        /// </summary>
        [Column("fail_reason")]
        public string FailReason { get; set; }

        /// <summary>
        /// 查询代发结果接口返回失败信息
        /// </summary>
        [Column("query_result_response")]
        public string QueryResultResponse { get; set; }

        /// <summary>
        /// 查询代发流水号
        /// </summary>
        [Column("tran_no")]
        public string TranNo { get; set; }

        /// <summary>
        /// 银行查询结果文件名称
        /// </summary>
        [Column("bank_filename")]
        public string BankFileName { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.Id; } }

        #endregion IEntity 成员
    }
}